@import "variables";

.markdown {
  line-height: 1.625;
  font-size: 1rem;

  // remove padding at the beginning of page
  > :first-child {
    margin-top: 0;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-weight: 700;
    line-height:1.5;
    a.anchor {
      opacity: 0;
      font-size: .75em;
      vertical-align: middle;
      text-decoration: none;
    }

    &:hover a.anchor, a.anchor:focus {
      opacity: initial;
    }
  }
  h2{
    margin:73px 0px 24px;
    position:relative;
    font-size:1.5rem;
    &:not(:first-child):before{
      top: -2rem;
      left: 0px;
      width: 100%;
      height: 1px;
      content: " ";
      position: absolute;
      background-color: $border-color;
    }
  }

  h3{
    font-size:1.25rem;
    margin:2rem 0 1.5rem;
  }

  h4{
    font-size:1rem;
    margin:1.5rem 0;
  }

  h5 {
    font-size: 0.875em;
    margin:1rem 0;
  }

  h6 {
    font-size: 0.75em;
    margin:0.875rem 0;
  }

  b,
  optgroup,
  strong {
    font-weight: 700;
  }

  a {
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }
  p{
    margin:0;
    margin-bottom:1.5rem;
  }
  ul{
    margin:0;
    padding:0;
    color:$menu-color;
    margin-bottom:1.5rem;
    padding-left:2rem;
  }

  img {
    display:inline-block;
    padding:3px;
    max-width: 300px;
    vertical-align: middle;
  }
  figure{
    margin: 2rem 0;
    figcaption{
      margin-top: 0;
      & *{
        color: rgb(157, 170, 182);
        margin: 0px;
        padding: 8px 0px;
        overflow: hidden;
        word-break: normal;
        font-weight: 400;
        text-align:center;
      }
    }
    img{
      max-width:100%;
      padding:0;
      cursor: zoom-in;
    }
  }
  h1,h2,h3,h4,h5,h6,li,a{
    img{
      height:1.5rem;
    }
  }
  

  code {
    padding: 0 $padding-4;
    background: $gray-100;
    border-radius: $border-radius;
    font-size: 0.875em;
  }

  pre {
    padding: $padding-16;
    background: $gray-100;
    border-radius: $border-radius;
    overflow-x: auto;

    code {
      padding: 0;
      background: none;
    }
  }

  blockquote {
    margin: $padding-16 0;
    padding-left: 0.75rem; //to keep total left space 16dp
    border-inline-start: $padding-4 solid $border-color;
    color: #74818D;
    :first-child {
      margin-top: 0;
    }
    :last-child {
      margin-bottom: 0;
    }
  }

  table {
    overflow: auto;
    display: block;
    border-spacing: 0;
    border-collapse: collapse;
    margin-top: $padding-16;
    margin-bottom: $padding-16;
    tr{
      padding:10px;
    }
    tr th,
    tr td {
      padding: $padding-8;
      border-bottom: 1px solid $border-color;
    }
    tr th{
      border-bottom-width: 2px;
      color:$gray;
    }
  }

  hr {
    height: $padding-1;
    border: none;
    background: $border-color;
  }

  ul,
  ol {
    padding-inline-start: $padding-16 * 2;
  }

  dl {
    dt {
      font-weight: bolder;
      margin-top: $padding-16;
    }

    dd {
      margin-inline-start: $padding-16;
      margin-bottom: $padding-16;
    }
  }

  // Special case for highlighted code with line numbers
  .highlight table tr {
    td:nth-child(1) pre {
      margin: 0;
      padding-inline-end: 0;
    }
    td:nth-child(2) pre {
      margin: 0;
      padding-inline-start: 0;
    }
  }

  details {
    padding: $padding-16;
    border: $padding-1 solid $border-color;
    border-radius: $border-radius;

    summary {
      line-height: 1;
      padding: $padding-16;
      margin: -$padding-16;
      cursor: pointer;
    }

    &[open] summary {
      margin-bottom: 0;
    }
  }
}

.markdown-inner {
  // Util class to remove extra margin in nested markdown content
  > :first-child {
    margin-top: 0;
  }
  > :last-child {
    margin-bottom: 0;
  }
}
